//CLASE DE TIPO DE LINEA

package paint;

import java.awt.*;
import java.awt.event.*;

public class DSel extends Dialog implements AdjustmentListener
{
    Panel main = new Panel ();
    Scrollbar w = new Scrollbar ( Scrollbar.VERTICAL, 0, 1, 0, 8 );
    F box = new F ( 186, 160 );
    Button cmdOk = new Button ();
    BasicStroke c = new BasicStroke ( 1f, BasicStroke.CAP_BUTT,
				      BasicStroke.JOIN_ROUND );
    int ancho = 0;
    float dash0[] =
	{
	0f};
    float dash1[] =
	{
	10.0f};
    float dash2[] =
	{
	7.0f, 1.0f};
    float dash3[] =
	{
	5.0f, 5.0f, 10.0f, 5.0f};
    float dash4[] =
	{
	10.0f, 14.0f, 12.0f, 10.0f, 12.0f, 14.0f};
    float dash5[] =
	{
	2.0f, 8.0f, 6.0f, 4.0f, 3.0f};
    float dash6[] =
	{
	6.0f, 4.0f, 11.0f, 2.0f, 4.0f};
    float dash7[] =
	{
	5.0f, 4.0f, 7.0f, 5.0f};
    float dash8[] =
	{
	6.0f, 5.0f, 4.0f, 8.0f, 2.0f, 7.0f};
    float ds[];
    public DSel ( Frame frame, boolean modal )
    {
	super ( frame, "", modal );
	setTitle ( "Selector Tipo de Linea" );
	enableEvents ( AWTEvent.WINDOW_EVENT_MASK );
	main.setLayout ( null );
	cmdOk.addActionListener (
	    new ActionListener ()
	{
	    public void actionPerformed ( ActionEvent e )
	    {
		DSel.this.hide ();
	    }
	}
	);
	w.setBounds ( new Rectangle ( 10, 10, 26, 160 ) );
	w.addAdjustmentListener ( this );
	main.setBounds ( new Rectangle ( 0, 0, 238, 218 ) );
	box.setBackground ( Color.white );
	box.setBounds ( new Rectangle ( 42, 10, 186, 160 ) );
	cmdOk.setLabel ( "Aceptar" );
	cmdOk.setBounds ( new Rectangle ( 10, 176, 218, 32 ) );
	main.add ( w, null );
	main.add ( box, null );
	main.add ( cmdOk, null );
	add ( main );
	setResizable ( false );
	pack ();
    }

    public void doit ()
    {
	ds = dash1;
	switch ( w.getValue () )
	{
	    case 0:
	    {
		ds = dash0;
		break;
	    }
	    case 1:
	    {
		ds = dash1;
		break;
	    }
	    case 2:
	    {
		ds = dash2;
		break;
	    }
	    case 3:
	    {
		ds = dash3;
		break;
	    }
	    case 4:
	    {
		ds = dash4;
		break;
	    }
	    case 5:
	    {
		ds = dash5;
		break;
	    }
	    case 6:
	    {
		ds = dash6;
		break;
	    }
	    case 7:
	    {
		ds = dash7;
		break;
	    }
	    case 8:
	    {
		ds = dash8;
		break;
	    }

	}
	if ( ds[0] != 0 )
	{
	    c = new BasicStroke ( ancho, BasicStroke.CAP_BUTT,
				  BasicStroke.JOIN_ROUND,
				  10.0f, ds, 0.0f );
	}
	else
	{
	    c = new BasicStroke ( ancho, BasicStroke.CAP_BUTT,
				  BasicStroke.JOIN_ROUND );
	}
	box.memg.clearRect ( 0, 0, box.w, box.h );
	box.memg.setStroke ( c );
	box.memg.drawLine ( 0, ( int ) ( box.h / 2 ), box.w,
			    ( int ) ( box.h / 2 ) );
	box.rp ();
    }

    public void adjustmentValueChanged ( AdjustmentEvent e )
    {
	doit ();
    }

    public void paint ( Graphics g )
    {
	super.paint ( g );
	doit ();
    }

    protected void processWindowEvent ( WindowEvent e )
    {
	if ( e.getID () == WindowEvent.WINDOW_CLOSING )
	{
	    this.hide ();
	}
	super.processWindowEvent ( e );
    }

}
